<?php
	$x = $_POST['msg'];
	$y = $_POST['keyword'];
	$z = $_POST['part'];
	$type = $_POST['type'];
	include("conn.php");
	if($type == "所有类型"){
		$stmt = $db->prepare("select * from file where name like ? or subject like ? or uploadtime like ? or year like ? order by $z $x");
		$stmt->execute(array("%$y%","%$y%","%$y%","%y%"));
	}
	else{
		$stmt = $db->prepare("select * from file where type = ? and (name like ? or subject like ? or uploadtime like ? or year like ?) order by $z $x");
		$stmt->execute(array($type,"%$y%","%$y%","%$y%","%y%"));
	}	
	$x=array();
	while($result= $stmt->fetch(PDO::FETCH_ASSOC))
		$x[] = $result;
	echo json_encode($x);
?>